package com.csh.szhm.adapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.csh.szhm.R;
import com.csh.szhm.utils.ActivityStartAndFinshAnimation;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public abstract class MyBaseAdapter<T> extends BaseAdapter {

	private boolean isSetReadView;
	protected List<T> mData = new ArrayList<T>();

	protected Context mContext;
	protected LayoutInflater mLayoutInflater;

	public String isNews;

	public MyBaseAdapter(Context c) {
		mContext = c;
		mLayoutInflater = LayoutInflater.from(c);
	}

	public void addData(List<T> ls) {
		if (ls != null) {
			mData.addAll(ls);
			notifyDataSetChanged();
		}
	}

	public void clearAll() {
		mData.clear();
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		// return mListData.size();//
		return mData.size();// 测试数据
	}

	@Override
	public T getItem(int position) {
		// TODO Auto-generated method stub
		return mData.get(position);
	}

	public List<T> getAllData() {
		return mData;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	protected void startMyActivity(Intent in, Class<?> cls) {
		in.setClass(mContext, cls);
		mContext.startActivity(in);
		ActivityStartAndFinshAnimation
				.ActivityStartAnimation((Activity) mContext);
	}

	@Override
	public abstract View getView(int position, View convertView,
			ViewGroup parent);

}
